const router=require('./index');

 
   
    let userLogin_fn=(ctx,next)=>{

         let users=[
            {
               id:1,
               name:'admin',
               password:'123'
            },
            {
               id:2,
               name:'user1',
               password:'111'
            }
         ]
         

         let username=ctx.request.body.username || ''
         let password=ctx.request.body.password || ''


         let user_pwd=users.filter(item=>{
            return item.name===username && item.password===password
         })

         /* console.log(user_pwd); */
         if(user_pwd.length>0){
            ctx.body='登录成功'
         }else{
            ctx.body='用户名或密码有误！'
         }   

     }




module.exports={
     
     "post /login":userLogin_fn,
  
}
